Skip to content

feat: add OIDC auth for external cluster scans#1526

Open
MaxRink wants to merge 1 commit into
mondoohq:mainfrom
MaxRink:codex/external-cluster-oidc-operator
Open

feat: add OIDC auth for external cluster scans#1526
MaxRink wants to merge 1 commit into
mondoohq:mainfrom
MaxRink:codex/external-cluster-oidc-operator

Conversation

@MaxRink

@MaxRink MaxRink commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add external cluster OIDC refresh-token auth that generates a short-lived bearer-token kubeconfig in an init container
  • keep OIDC credentials pod-local: reconciliation now checks only Secret existence and lets the init container validate the configured key
  • pass proxy environment variables into the OIDC init container unless skipProxyForCnspec is set
  • keep the external-cluster active deadline on external-cluster scan Jobs without applying it to the local Kubernetes resource scan CronJob
  • document OIDC auth, generated kubeconfig security boundaries, and test behavior

Review fixes

  • add HTTPS-only curl protocol restrictions to OIDC discovery, refresh, device token, and token-exchange calls
  • replace the fragile unquoted issuer CA curl-args string with a curl_oidc helper that quotes the CA path
  • pass OIDC mount paths through env vars instead of interpolating path constants into the shell script
  • document that the shell JSON extractor only supports top-level simple OIDC string fields
  • mount OIDC credential Secrets with mode 0440
  • validate OIDC scope items in the CRD with a restrictive item pattern

Validation

  • git diff --check
  • make manifests
  • rg -n "scopes:|pattern: \\^\\[A-Za-z0-9" config/crd/bases/k8s.mondoo.com_mondooauditconfigs.yaml charts/mondoo-operator/crds/k8s.mondoo.com_mondooauditconfigs.yaml charts/mondoo-operator/files/crds/k8s.mondoo.com_mondooauditconfigs.yaml
  • go test ./controllers/k8s_scan -run 'TestExternalClusterCronJob_OIDCAuth|TestOIDCInitContainerDefaultsCredentialKeys|TestDeploymentHandlerSuite/TestReconcile_ExternalCluster_OIDCAuth'
  • go test ./controllers/k8s_scan
  • go test ./controllers/k8s_scan ./pkg/utils/k8s
  • make lint/actions
  • make lint
  • kubectl --context kind-mondoo-oidc-kind apply --dry-run=server -f config/crd/bases/k8s.mondoo.com_mondooauditconfigs.yaml
  • kubectl --context kind-mondoo-oidc-kind apply --dry-run=server -f config/samples/k8s_v1alpha2_mondooauditconfig.yaml

Notes

  • The controller intentionally does not read refresh-token Secret data during reconciliation. Missing or empty key data is reported by the generated init container in the scanner pod.

@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Test Results

0 tests  ±0   0 ✅ ±0   0s ⏱️ ±0s
0 suites ±0   0 💤 ±0 
0 files   ±0   0 ❌ ±0 

Results for commit cfe0392. ± Comparison against base commit 70733ca.

♻️ This comment has been updated with latest results.

@MaxRink MaxRink force-pushed the codex/external-cluster-oidc-operator branch from 453ea09 to b7971ec Compare June 19, 2026 00:26
@MaxRink MaxRink marked this pull request as ready for review June 19, 2026 08:15
@MaxRink MaxRink force-pushed the codex/external-cluster-oidc-operator branch from 1bd80ad to 1e1e10b Compare June 19, 2026 08:39
mondoo-code-review[bot]
mondoo-code-review Bot previously approved these changes Jun 19, 2026

@mondoo-code-review mondoo-code-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds OIDC refresh-token authentication for external Kubernetes cluster scans with thorough validation, secure init-container design, and comprehensive tests.

Comment thread controllers/k8s_scan/resources.go Outdated
Comment thread controllers/k8s_scan/resources.go
mondoo-code-review[bot]
mondoo-code-review Bot previously approved these changes Jun 19, 2026

@mondoo-code-review mondoo-code-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds OIDC refresh-token authentication for external Kubernetes cluster scans with solid security controls.

Comment thread controllers/k8s_scan/resources.go Outdated
Comment thread controllers/k8s_scan/resources.go Outdated

@mondoo-code-review mondoo-code-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OIDC auth for external cluster scans introduces a new authentication method with generally solid security practices but has an inconsistent secret file permission.

Comment thread controllers/k8s_scan/resources.go Outdated
Comment thread controllers/k8s_scan/resources.go Outdated
Comment thread api/v1alpha2/mondooauditconfig_types.go

@mondoo-code-review mondoo-code-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well-structured OIDC authentication support for external cluster scans with strong security defaults.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant